﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using NUnit.Framework.Constraints;
using Simhopp.Model;

namespace NUnit.Framework.Tests
{
    [TestFixture]
    class TestDiver
    {
        [Test]
        public void AddDive()
        {
            //Check if added
            Diver diver = new Diver();
            diver.AddDive(1, "volt", 2.5, "A101", 1);
            bool equal = false;
            Dive dive = diver.GetDive(1);
            if (dive.ID == 1 &&
                dive.Name == "volt" &&
                dive.Difficulty == 2.5 &&
                dive.NameCode == "A101" &&
                dive.Score == 0 &&
                dive.DiveNumber == 1)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void UpdateDive()
        {
            //Check if updated
            Diver diver = new Diver();
            diver.AddDive(1, "volt", 2.5, "A101",1);
            bool equal = false;
            diver.UpdateDive(1, "skruv", 3.0, "B101", 0,2);
            Dive dive = diver.GetDive(1);
            if (dive.ID == 1 &&
                dive.Name == "skruv" &&
                dive.Difficulty == 3.0 &&
                dive.NameCode == "B101" &&
                dive.Score == 0 &&
                dive.DiveNumber == 2)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void RemoveDive()
        {
            //Check if removed
            Diver diver = new Diver();
            diver.AddDive(1, "volt", 2.5, "A101",1);
            bool equal = false;
            diver.RemoveDive(1);
            Dive dive = diver.GetDive(1);
            if (dive == null)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void CalculateTotalPoints()
        {
            //Check if calculation is correct
            Diver diver = new Diver();
            bool equal = false;
            diver.AddDive(1, "volt", 3, "B10",1);
            diver.AddDive(2, "skruv", 2, "AA10",2);
            diver.AddDive(3, "headbang of doom", 25, "C10",3);
            foreach (var dive in diver.DiveList)
            {
                dive.AddDiveResult(5);
            }
            diver.CalculateTotalPoints();
            if (diver.TotalPoints == 15)
                equal = true;
          
            Assert.AreEqual(equal, true);
        }
    }
}
